package org.kazuhiko.pokemon3d.entity;

import java.util.ArrayList;

public abstract class Entity
{
	private int id;
	
	private String name;
	
	private ArrayList<Flag> flags;
	
	public Entity( int id, String name )
	{
		this.id = id;
		this.name = name;
		flags = new ArrayList<Flag>();
	}
	
	public int getId()
	{
		return id;
	}
	
	public void setId( int id )
	{
		this.id = id;
	}
	
	public String getName()
	{
		return name;
	}
	
	public void setName( String name )
	{
		this.name = name;
	}
	
	public ArrayList<Flag> flags()
	{
		return flags;
	}
	
	public void addFlag( Flag flag )
	{
		if( !flags.contains( flag ) )
		{
			flags.add( flag );
		}
	}
	
	public void removeFlag( Flag flag )
	{
		if( flags.contains( flag ) )
		{
			flags.remove( flag );
		}
	}
	
	public Flag getFlag( Flag flag )
	{
		Flag ret = null;
		int index = 0;
		
		while( index < flags.size() && ret == null )
		{
			if( flags.get( index ).equals( flag ) )
			{
				ret = flags.get( index );
			}
		}
		
		return ret;
	}
	
	public boolean hasFlag( Flag flag )
	{
		boolean found = false;
		int index = 0;
		
		while( index < flags.size() && !found )
		{
			if( flags.get( index ).equals( flag ) )
			{
				found = true;
			}
			index++;
		}
		
		return found;
	}
}
